<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="manage.BugManage"%>

<%@ page  import="object.Module"%>
<%@ page import="java.sql.*"  %>
<%@ page import="java.util.ArrayList"%>
<%@ include file="JS/session.jsp" %>
<%@ page  import="manage.BugManage"%>
<jsp:useBean id="procedure" scope="page" class="Procedure.UseProcedure"/>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
<script type="text/javascript" language="javascript"> 
function add(fromID,toID) 
 { 
var v;
var v1;
var j=0;
var s1=document.getElementById(fromID); 
var l=s1.length; 
for(var i=0;i<l;i++) 
{ 
   if(s1.options[i].selected==true) 
    { 
      v=s1.options[i].value; 
      v1=s1.options[i].text;
      s2=document.getElementById(toID); 
      m=0; 
      for(k=0;k<s2.length;k++) 
      { 
        if(s2.options[k].value==v) 
         { 
              m=1; 
         }
       } 
       if(m==0) 
         { 
          var varItem = new Option(v1, v); 
          s2.options.add(varItem); 
         } 
     else 
       { 
          alert('已经存在此选项'); 
       } 
    j=1;
    } 

} 
 if(j!=1) 
 { 
  alert('请选择你要添加的选项'); 
 } 
} 
function del(desID) 
{ 
   s2=document.getElementById(desID); 
   l=s2.length; 
   j=0; 
   for(i=0;i<l;i++) 
   { 
     if(s2.options[i].selected==true) 
      { 
       s2.options.remove(i); 
       s2.length=l-1; 
       j=1; 
       break;
      } 
    } 
   if(j==0) 
    { 
      alert('请选择你要删除的选项'); 
    } 
return false; 
}

function subform()
{
   var _sel = document.getElementById('User2') ;
   for(var i = 0 ;i<_sel.length ;i++)
   {
       _sel.options[i].selected = true ;
    }
   var _pro = document.getElementById('MailTo2') ; 
   for(var i = 0 ;i<_pro.length ;i++)
   {
       _pro.options[i].selected = true ;
    }
    
   
  }

 
</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加Bug</title>
<link href="css/foreground.css" rel="stylesheet" type="text/css" />
</head>

<BODY id=css-zen-garden>
<script language="JavaScript"> 
<!--
  var subcat = new Array(); 
  var usercat= new Array(); 
<%
  int h=0;
  int puser=0;
  String userid1=(String)session.getAttribute("UserID");
 if(userid1!=null)
 {
  int UserID1=Integer.parseInt(userid1);
  ResultSet rs1=procedure.getProjectLists(UserID1);

  while(rs1.next())
  {
    
   int project1=rs1.getInt("ProjectID");
   ArrayList list=procedure.getModules(project1);
   ResultSet rs2=procedure.getUsers(project1);
   for(int count=0;count<list.size();count++)
   {
    Module module=(Module)list.get(count);
    String modulename=module.getModuleName();
    int moduleid=module.getModuleID();
  %>
    subcat[<%= h%>]=new Array('<%= project1%>','<%= modulename%>','<%= moduleid%>')
    
  <%
    h++;
   }
    
   while(rs2.next()) 
    {
     String username=rs2.getString("UserName");
     int userid=rs2.getInt("UserID");
 %>
    usercat[<%= puser%>]= new Array('<%= project1%>','<%= username%>','<%= userid%>')    
  <%
   
     puser++;  
    }
    rs2.close();
 }
 
  rs1.close();
  

 
 
 }

%>
function changeselect1(locationid)   
{   document.AddBugForm.User.length=0;
    document.AddBugForm.module.length = 0;   
    document.AddBugForm.MailTo.length=0;
    document.AddBugForm.module.options[0] = new Option('==选择模块==','0');   
    for (i=0; i<subcat.length; i++)   
    {   
        if (subcat[i][0] == locationid)   
        {document.AddBugForm.module.options[document.AddBugForm.module.length] = new Option(subcat[i][1], subcat[i][2]);}   
    }  
    
    for(i=0;i<usercat.length;i++)
    {
     if (usercat[i][0] == locationid)   
        {document.AddBugForm.User.options[document.AddBugForm.User.length] = new Option(usercat[i][1], usercat[i][2]);
         document.AddBugForm.MailTo.options[document.AddBugForm.MailTo.length] = new Option(usercat[i][1], usercat[i][2]);
        
        
        }   
    
    } 
}  

</script>

<DIV id=container>
<DIV id=intro>
<DIV id=quickSummary>
 <p class=p2>欢迎，<%=session.getAttribute("RealName") %>;<a href="login.jsp">退出</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="EditUser.jsp">修改资料</a>&nbsp;&nbsp;
    <%
     String level= null;
     level=(String)session.getAttribute("UserLevel");
     if(level!=null&&level.equals("0"))
     {
     %> 
      <a href="admin/AddGroup.jsp">进入后台</a>
      <%
       }
       %></p>
</DIV>
<DIV id=buginfo>
<H3><SPAN>添加BUG</SPAN></H3>

<form id="AddBugForm" name="AddBugForm" method="post"  enctype="multipart/form-data"   action="addBug">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_style">
  <tr bgcolor="#52514E">
    <td colspan="6">新建一个BUG</td>
  </tr>
  <tr bgcolor="#52514E">
    <td>项目和模块</td>
    <td align="left">
       <select name="project" id="project" onChange="changeselect1(this.value)">
      <option>==请选择项目==</option> 
         <%   
	            String puserid=(String)session.getAttribute("UserID");
	            if(puserid!=null)
	            {  int UserID=Integer.parseInt(puserid);
	               ResultSet rs=procedure.getProjectLists(UserID);
	               while(rs.next())
	               { String ProjectName=rs.getString("ProjectName");
	                 int ProjectID=rs.getInt("ProjectID");
	         %> 
	       <option value="<%= ProjectID%>"><%=ProjectName %></option>
	          <% 
	             }
	                rs.close();
            }
          %>
          </select>
        <select name="module" id="module">
        <option>==请选择模块==</option> 
        </select>    </td>
  </tr>
  <tr bgcolor="#52514E">
    <td>Bug标题</td>
    <td align="left">
      <input type="text" name="BugTitle" id="BugTitle" /> </td></tr>
         <tr bgcolor="#52514E">
    <td>Build版本</td>
    <td align="left">
     <input type="text" name="BugBuild" id="BugBulid" /></td>
  </tr> 
    <tr bgcolor="#52514E">
    <td>类型、操作系统和严重程度以及优先级</td>
    <td  align="left"><select name="BugType" id="BugType">
       
        <option selected="selected" value="1">资源泄露</option>
        <option value="2">内存溢出</option>
        <option value="3">同步问题</option>
        <option value="4">进程间通信问题</option>
        <option value="5">逻辑错误</option>
        <option value="6">莫名其妙的崩溃</option>
        <option value="7">其他</option>
        </select>
        <select name="BugOS" id="BugOS">
        <option selected="selected" value="Windows XP">Windows XP</option>
        <option value="Windows 2000">Windows 2000</option> 
        <option value="Windows NT">Windows NT</option>
        <option value="Windows 98">Windows 98</option>
        <option value="Linux">Linux</option>
        <option value="unix">unix</option>
        <option value="其他">其他</option>
        </select>
        <select name="BugSeverity" id="BugSeverity">
        <option selected="selected" value="1" >1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        </select>
          <select name="BugPriority" id="BugPriority">
        <option selected="selected" value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        </select>
        </td>
  </tr>
    <tr bgcolor="#52514E">
    <td>指派</td>
    <td align="left">
    <table>
    <tr bgcolor="#52514E" >
     
      <td align="left"><select name="User" size="4" multiple="multiple"  class="selectlist2"  id="User">

      </select></td>
      <td align="left"><input name="button22" type="button" class="button" id="button22" value=" &gt;&gt; " onClick="add('User','User2')"/>
        <br />
      <input name="button23" type="button" class="button" id="button23" value=" &lt;&lt; " onClick="del('User2')"/></td>
      <td align="left" ><select name="User2" size="4" multiple="multiple" class="selectlist2" id="User2">
      </select></td>
    </tr></table>       
</td>
  </tr>
    <tr bgcolor="#52514E">
    <td>发信</td>
    <td align="left">
    <table>
       <tr >
     
      <td align="left" ><select name="MailTo" size="4" multiple="multiple" class="selectlist2">
      
      </select></td>
      <td align="left" ><input name="button3" type="button" class="button" id="button3" value=" &gt;&gt; " onClick="add('MailTo','MailTo2')"/>
        <br />
      <input name="button2" type="button" class="button" id="button2" value=" &lt;&lt; " onClick="del('MailTo2')" />      </td>
      <td align="left" ><select name="MailTo2" size="4" multiple="multiple" class="selectlist2">
      </select></td>
    </tr>
    </table>
    
    
    </td>
  </tr>
    <tr bgcolor="#52514E">
    <td>Bug描述</td>
    <td align="left">
      <textarea name="ReproSteps" id="ReproSteps" cols="45" rows="8">
[步骤]
1.
2.
3.
[结果]
[期望]
      </textarea>      </td>
  </tr>
    <tr bgcolor="#52514E">
    <td>相关文件</td>
    <td align="left"><input name="filename" type="file" id="filename" size="25" maxlength="200" dataType="Require" msg="选择上传文件" />
    <label>小于8兆,允许rar,doc,txt,pdf文件</label>
    </td>
  </tr>
   <tr bgcolor="#52514E">
    <td>新文件名</td>
    <td align="left"><input name="title" type="text" id="title" size="30" maxlength="30"  dataType="Require" msg="输入题目" />
    </td>
  </tr>
  
  <tr bgcolor="#52514E">
    <td colspan="6">  <input type="submit" name="button" id="button" value="创建Bug" onClick="subform()"  /></td>
  </tr>
</table> 
 </form>
</DIV></DIV>
<DIV id=supportingText></DIV>
<DIV id=linkList>
<DIV id=linkList2>
<DIV id=lselect>
<H3 class=select></H3>
<UL>
 <li><a href="QueryBug.jsp?QueryMode=Whole"><span 
  class=accesskey>查看BUG</span></a> </li>
 <li><a href="AddBug.jsp"><span 
  class=accesskey>创建BUG</span></a> </li>
  </UL>
</DIV>
<DIV id=lresources>
<H3 class=resources></H3>
<UL>
 <li><a href="QueryBug.jsp?QueryMode=AssignedTo"><span class=accesskey>指派给我的BUG</span></a> </li>
 <li><a href="QueryBug.jsp?QueryMode=Opened"><span class=accesskey>由我创建的BUG</span></a> </li>
  </UL>
</DIV></DIV></DIV></DIV></BODY>
</html>